module.exports = {
    ModalView: function() {
        function o() {
            var o = getCurrentPages(), t = o[o.length - 1];
            return this.__page = t, Object.assign(t, a), t.setData(e), t.modalView = this, this;
        }
        var e = {
            "__modalView__.title": null,
            "__modalView__.inputFields": null,
            "__modalView__.confirm": null,
            "__modalView__.formData": null,
            "__modalView__.confirmation": !1,
            "__modalView__.confirmationText": null
        }, a = {
            __modalView__onTextBlur: function(o) {
                var e = o.currentTarget.dataset.field_index, a = this.data.__modalView__.formData;
                a[e] = o.detail.value, this.setData({
                    "__modalView__.formData": a
                });
            },
            __modalView__onPickerChange: function(o) {
                var e = o.currentTarget.dataset.field_index, a = this.data.__modalView__.inputFields[e].fieldDatasource[parseInt(o.detail.value)], t = this.data.__modalView__.formData;
                t[e] = a, this.setData({
                    "__modalView__.formData": t
                });
            },
            __modalView__onConfirm: function(o) {
                var e = this, a = this.data.__modalView__.formData;
                console.log(this.data.__modalView__.inputFields), e.savePosterImage(this.data.__modalView__.inputFields[0].fieldDatasource), 
                this.data.__modalView__.confirmation ? (e.setData({
                    "__modalView__.reveal": !1
                }), wx.showModal({
                    title: "",
                    content: this.data.__modalView__.confirmationText,
                    success: function(o) {
                        o.confirm ? (e.__modalView__onHideModal(), "function" == typeof e.data.__modalView__.confirm && e.data.__modalView__.confirm(a)) : e.setData({
                            "__modalView__.reveal": !0
                        });
                    }
                })) : (e.__modalView__onHideModal(), "function" == typeof e.data.__modalView__.confirm && e.data.__modalView__.confirm(a));
            },
            savePosterImage: function(o) {
                wx.saveImageToPhotosAlbum({
                    filePath: o,
                    success: function(o) {
                        console.log(o), wx.showModal({
                            title: "提示",
                            content: "二维码海报已存入手机相册，赶快分享到朋友圈吧",
                            showCancel: !1,
                            success: function(o) {}
                        });
                    },
                    fail: function(o) {
                        console.log(o), "saveImageToPhotosAlbum:fail auth deny" === o.errMsg && (console.log("再次发起授权"), 
                        wx.showModal({
                            title: "用户未授权",
                            content: "如需保存海报图片到相册，需获取授权.是否在授权管理中选中“保存到相册”?",
                            showCancel: !0,
                            success: function(o) {
                                o.confirm && (console.log("用户点击确定"), wx.openSetting({
                                    success: function(o) {
                                        console.log("打开设置", o.authSetting), wx.openSetting({
                                            success: function(o) {
                                                console.log(o), o.authSetting["scope.writePhotosAlbum"] ? console.log("获取保存到相册权限成功") : console.log("获取保存到相册权限失败");
                                            }
                                        });
                                    }
                                }));
                            }
                        }));
                    }
                });
            },
            __modalView__onCancel: function(o) {
                this.__modalView__onHideModal();
            },
            __modalView__onPreventTouchMove: function(o) {},
            __modalView__onHideModal: function() {
                var o = this;
                wx.createAnimation().opacity(0).step(), o.setData({
                    "__modalView__.reveal": !1
                });
            },
            posterImageClick: function(o) {
                var e = o.currentTarget.dataset.src;
                wx.previewImage({
                    urls: [ e ]
                });
            }
        };
        return o.prototype.showModal = function(o) {
            var e = this.__page;
            wx.createAnimation().opacity(1).step(), o && e.setData({
                "__modalView__.title": o.title,
                "__modalView__.inputFields": o.inputFields,
                "__modalView__.confirm": o.confirm,
                "__modalView__.formData": new Array(o.inputFields.length),
                "__modalView__.confirmation": !!o.confirmation && o.confirmation,
                "__modalView__.confirmationText": o.confirmationText ? o.confirmationText : null
            }), e.setData({
                "__modalView__.reveal": !0
            });
        }, new o();
    }
};